package basic.sort;

import java.util.Arrays;

/**
 * @创建人 MBY381
 * @创建时间 2022/4/26 13:45
 * @描述 暂无
 */
public class A_4_QuickSort {
    public static void main(String[] args) {
        int[] nums1 = new int[]{0xE3, 381, 8, 6, 4, 7, 9, 3, 5, 2, 1, 782, 696, 259, 0x15};
        System.out.println("正确答案：    [1, 2, 3, 4, 5, 6, 7, 8, 9, 21, 227, 259, 381, 696, 782]");
        quickSort(nums1,0, nums1.length-1);
        System.out.println(Arrays.toString(nums1));
    }
    public static void quickSort(int[] nums, int start, int end) {
        if (start >= end) return;
        int left = start, right = end, value = nums[left];
        while (left < right) {
            while (left < right && nums[right] > value) {
                right--;
            }
            nums[left] = nums[right];
            while (left < right && nums[left] < value) {
                left++;
            }
            nums[right] = nums[left];
            nums[left] = value;
            quickSort(nums, start, left - 1);
            quickSort(nums, left + 1, end);
        }
    }
}
